<%@ page language="java" contentType="text/html; charset=UTF-8"	pageEncoding="UTF-8"%>

<%@ include file="../header.jsp"%>

<div id="sub_img">
	<img src="../images/13584897220.jpg" width="1000" height="372" alt="">
</div>
<div id="container">
	<div id="scontents">

		<h2 id="sub_title">
			<span class="Etitle">NOTICE</span><span class="ktitle">공지사항</span>
		</h2>
		
	<script>
	function FieldCheckInput(field, msg) {
		field = eval('document.rboard.'+field);
		if(!field.value) {
			alert(msg);
			field.focus();
			return true;
		}
		return false;
	}

	function InputSubmit() {
		form = document.rboard;

		
		
		if(FieldCheckInput("nb_name", "이름을 기재해 주세요.")) return false;
		if (!IsNullInput(form.nb_name.name)) {
			alert('[이름]은 공백이 없어야 합니다.');
			form.nb_name.focus();
			form.nb_name.select();
			return false;
		}
		if(FieldCheckInput("nb_pw", "비밀번호를 기재해 주세요.")) return false;
		if(!IsPWInput(form.nb_pw.name)) {
			alert('[비밀번호]는 4~12자의 영문 또는 숫자로 조합된 문자열이어야 합니다.');
			form.nb_pw.focus();
			form.nb_pw.select();
			return false;
		}
		
		
		if(FieldCheckInput("nb_title", "제목을 기재해 주세요.")) return false;
		if (!IsNullInput(form.nb_title.name)) {
			alert('[제목]은 공백이 없어야 합니다.');
			form.nb_title.focus();
			form.nb_title.select();
			return false;
		}
		if(FieldCheckInput("nb_text", "내용을 기재해 주세요.")) return false;

		
		return true;
	}

	function FormInputSubmit() {
		if(InputSubmit()) document.rboard.submit();
		else return;
	}

	function IsNullInput(formname) {
		var form = eval("document.rboard."+formname);
		var chr=form.value.substr(0,1);
		if(chr==' ') return false;
		return true;
	}

	function IsPWInput(formname) {
		var form = eval('document.rboard.'+formname);
		if(form.value.length<4 || form.value.length >13) {
			return false;
		}
		for(var i=0; i<form.value.length; i++) {
			var chr=form.value.substr(i,1);
			if((chr < "0" || chr > "9") && (chr < "a" || chr > "z") && (chr < "A" || chr > "Z")) {
				return false;
			}
		}
		return true;
	}

	function ChkLen() {
		var msgtext, msglen;
		msgtext = document.rboard.board_content.value;
		msglen = parseInt(document.getElementById("byteint").innerHTML);
		var i=0,l=0;
		var temp,lastl;

		//길이를 구한다.
		while(i < msgtext.length) {
			temp = msgtext.charAt(i);

			if (escape(temp).length > 4) l+=2;
			else if (temp!='\r') l++;

			// OverFlow
			if(l>4000) {
				alert("내용의 허용 길이 이상의 글을 쓰셨습니다.\n메시지란에는 한글 2000자, 영문4000자까지만 쓰실 수 있습니다.");
				temp = document.rboard.board_content.value.substr(0,i);
				document.rboard.board_content.value = temp;
				l = lastl;
				break;
			}
			lastl = l;
			i++;
		}
		document.getElementById("byteint").innerHTML=l;
	}

	function historyback() {
		document.location.href = 'http://h-ps011u.monowebs.co.kr/board/index.php?board=reviewboard';
	}

	window.onload = function() {
		
		document.rboard.nb_name.focus();
		
		
	}
</script>
		<div id="notice">
			<form method="post" name="rboard" 
				action="<%=path%>/BoardInsert.admin"
				onsubmit="return InputSubmit()">
				<div id="board_write">
					<table cellpadding="0" cellspacing="0" border="0" width="100%"
						summary="">
						<colgroup>
							<col width="120">
							<col width="280">
							<col width="120">
							<col width="280">
						</colgroup>
						<tbody>
							<tr>
								<th scope="row" class="required">공지사항 분류</th>
								<td class="borderR" colspan="3">
								<select name="nb_type">
								<option value="1" selected="selected">이용후기 공지</option>
								<option value="2">문의사항 공지</option>								
								</select>
								</td>
							</tr>
							<tr>
								<th scope="row" class="required">글쓴이</th>
								<td class="borderR"><input type="text" maxlength="64"
									name="nb_name" value="" class="input230"></td>
								<th scope="row" class="required">비밀번호</th>
								<td><input type="password" maxlength="12" name="nb_pw"
									value="" class="input227"></td>
							</tr>
							<tr>
								<th scope="row" class="required">제목</th>
								<td colspan="3"><input type="text" name="nb_title"
									value="" class="input735"></td>
							</tr>
							<tr>
								<th scope="row" class="required">내용</th>
								<td colspan="3"><textarea name="nb_text" cols="100"
										rows="17" onchange="ChkLen()" onkeyup="ChkLen()"></textarea> <span
									class="max_txt"><span id="byteint">0</span>/4000 byte</span></td>
							</tr>

						</tbody>
					</table>
				</div>

				<div id="btn_area">

					<a href="<%=path%>/boardAdmin.admin" target="_self"> 
					<img class="btn_list" src="http://h-ps011u.monowebs.co.kr/skin/board/basic_list/image/btn_list.gif"
						width="59" height="21" alt="목록"></a> <a
						href="javascript:FormInputSubmit()"><img class="btn_save"
						src="http://h-ps011u.monowebs.co.kr/skin/board/basic_list/image/btn_board_save.gif"
						width="59" height="21" alt="글등록"></a>
				</div>
			</form>
		</div>
	</div>
	
	</div>
	
	<%@include file="../footer.jsp"%>